<!doctype html>
<html lang="en-US">
<head>
    <meta charset="UTF-8">
    <title></title>

</head>
<body>
<script type="text/javascript">
    window.onbeforeunload = function(){
        return "onbeforeunload";
    };

</script>


<a href="javascript:void(0)">test</a>

<script type="text/javascript">
    if(document.attachEvent){
        document.attachEvent('onclick',function(event){
            //debugger;
            if(event.srcElement.href && event.srcElement.href.indexOf("javascript:") !=-1){
                window.event.returnValue = false;
            }
        },false);
    }
</script>
</body>
</html>